include_directories(
  ${CMAKE_CURRENT_SOURCE_DIR}
  ${CMAKE_CURRENT_SOURCE_DIR}/..
  ${CMAKE_CURRENT_BINARY_DIR}/..
  ${CMAKE_SOURCE_DIR}/utils
)

macro(CPP_ADD_SIMPLETEST exe)
  string(REPLACE "-" "" test_name ${exe})
  set(${test_name}_SOURCES
    ${ARGN}
  )
  poppler_add_test(${exe} BUILD_CPP_TESTS ${${test_name}_SOURCES})
  target_link_libraries(${exe} poppler-cpp)
  if(MSVC)
    target_link_libraries(${exe} poppler ${poppler_LIBS})
  endif(MSVC)
endmacro(CPP_ADD_SIMPLETEST)


cpp_add_simpletest(poppler-dump poppler-dump.cpp ${CMAKE_SOURCE_DIR}/utils/parseargs.cc)
target_link_libraries(poppler-dump poppler)

cpp_add_simpletest(poppler-render poppler-render.cpp ${CMAKE_SOURCE_DIR}/utils/parseargs.cc)
target_link_libraries(poppler-render poppler)


cpp_add_simpletest(poppler-debug poppler-debug.cpp
  ${CMAKE_SOURCE_DIR}/utils/parseargs.cc
  ${CMAKE_SOURCE_DIR}/utils/extractpdf.cc
  ${CMAKE_SOURCE_DIR}/utils/extractpdf.h
  ${CMAKE_SOURCE_DIR}/utils/ImageOutputDev.cc
  ${CMAKE_SOURCE_DIR}/utils/ImageOutputDev.h
)
target_link_libraries(poppler-debug poppler-cpp poppler)

if(MSVC)
  target_compile_definitions(poppler-debug PRIVATE _CRT_SECURE_NO_WARNINGS)
  target_compile_definitions(poppler-debug PRIVATE _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING)
endif()

if(UNIX)
  target_link_libraries(poppler-debug stdc++fs)
endif()